Setup
print(paste0('../../../', '../motif_analysis/output/first_try/report/summary_table.txt'))
## [1] "../../../../motif_analysis/output/first_try/report/summary_table.txt"
if('../motif_analysis/output/first_try/report/summary_table.txt' != '') {
highlight.snp.df <- read.table(paste0('../../../', '../motif_analysis/output/first_try/report/summary_table.txt'), header = T)
} else {
highlight.snp.df <- NULL
}
rds.dirs <- strsplit('output/heart_motif_snp/Heart_Atrial_Appendage/fine-map__susie/,output/heart_motif_snp/Heart_Left_Ventricle/fine-map__susie/,output/heart_motif_snp/Muscle_Skeletal/fine-map__susie/', ',')[[1]]
output <- list()
for(rds.dir in rds.dirs) {
tissue <- basename(dirname(rds.dir))
cat('#', tissue, '
', '
')
rdss <- Sys.glob(paste0('../../../', rds.dir, '/', '*.rds'))
for(rds in rdss) {
gene <- sub('.rds', '', basename(rds), fixed = T)
cat('##', gene, '\n', '\n')
out <- readRDS(rds)
cs <- susieR::susie_get_CS(out$fitted, t(data.matrix(out$X[, -ncol(out$X)])), coverage = .95)
# output[[length(output) + 1]] <- paste0(capture.output(pander(cs$purity)), collapse = '\n')
pander(cs$purity)
pip <- susieR::susie_get_PIP(out$fitted, cs$cs_index)
coordinate <- as.numeric(str_match(out$X$SNP_ID, '[0-9]+_([0-9]+)_[A-Za-z]+_[A-Za-z]+_[A-Za-z0-9]+')[, 2])
df <- data.frame(coordinate = coordinate, pip = pip)
df$cs <- -1
if(length(cs$cs_index) != 0) {
for(i in 1 : length(cs$cs_index)) {
df$cs[cs$cs[[i]]] <- cs$cs_index[i]
}
}
p <- ggplot(df) + geom_point(aes(x = coordinate, y = pip, color = factor(cs)))
p <- p + ggtitle('PIP (red line: leadingSNP; blue line: candidateSNP)')
if(!is.null(highlight.snp.df)) {
highlight.snp <- highlight.snp.df[highlight.snp.df$ensembl_gene_id == str_match(gene, '([A-Za-z0-9]+).[A-Za-z0-9]+')[, 2] & highlight.snp.df$tissue == tissue, ]
leading.snp <- as.numeric(str_match(highlight.snp$leading_eqtl[1], '[0-9]+_([0-9]+)_[A-Za-z]+_[A-Za-z]+_[A-Za-z0-9]+')[, 2])
candidate.snp <- unique(as.numeric(str_match(highlight.snp$motif_snp, '[0-9]+_([0-9]+)_[A-Za-z]+_[A-Za-z]+_[A-Za-z0-9]+')[, 2]))
p <- p + geom_vline(xintercept = candidate.snp, color = 'blue')
}
p <- p + geom_vline(xintercept = leading.snp, color = 'red')
x <- as.widget(ggplotly(p))
output[[length(output) + 1]] <- x
cat(renderTags(x)$html)
cat('\n', '\n')
}
}
Heart_Atrial_Appendage
ENSG00000103091.10
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000105738.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000114450.5
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000139880.15
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000141542.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000154229.7
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000177963.8
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000185615.11
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000187860.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000232112.3
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
Heart_Left_Ventricle
ENSG00000103091.10
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000105738.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000114450.5
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000139880.15
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000141542.6
| 0.9932 |
0.9966 |
0.9966 |
| 0.5833 |
0.8071 |
0.8274 |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000154229.7
| 0.9665 |
0.9876 |
0.9892 |
| 0.9883 |
0.9946 |
0.9946 |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000177963.8
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000185615.11
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000187860.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000232112.3
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
Muscle_Skeletal
ENSG00000105738.6
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000139880.15
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000141542.6
| 0.9924 |
0.9962 |
0.9962 |
| 1 |
1 |
1 |
| 0.6587 |
0.8294 |
0.8294 |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000154229.7
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000177963.8
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000185615.11
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000187860.6
| min.abs.corr |
mean.abs.corr |
median.abs.corr |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
ENSG00000232112.3
| 0.9851 |
0.9966 |
1 |
| 0.9885 |
0.9956 |
0.9953 |
## Warning: 'as.widget' is deprecated.
## Use 'as_widget' instead.
## See help("Deprecated")
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`